package patrol.mobile.com.mobilepatrol.adapter;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImagePreviewDelActivity;

import java.util.ArrayList;
import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.view.DengbainImageView;

public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {
    List<String> imagePath;

    public ImageAdapter(List<String> imagePath) {
        this.imagePath = imagePath;
    }

    @Override
    public ImageAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.iten_image_layuot, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ImageAdapter.ViewHolder holder, int position) {
        Log.e("图片地址",imagePath.get(position));
        Glide.with(holder.itemView.getContext()).load(imagePath.get(position)).into(holder.dengbainImageView);

    }

    @Override
    public int getItemCount() {
        return imagePath == null ? 0 : imagePath.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        DengbainImageView dengbainImageView;

        public ViewHolder(View itemView) {
            super(itemView);
            dengbainImageView = itemView.findViewById(R.id.itemDengbainImageView);

        }
    }
}
